package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.exception.SzException;
import com.xueyi.aixihu.reqeust.AuditFinanceReq;
import com.xueyi.aixihu.reqeust.FindAuditFinanceDto;
import com.xueyi.aixihu.reqeust.OpenNewsReq;
import com.xueyi.aixihu.response.base.BaseResponse;
import com.xueyi.aixihu.service.FinanceAuditService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * @author lvyi
 * @date : 2023/6/29
 * @Description :
 */
@RestController
@AllArgsConstructor
public class FinanceAuditController extends BaseController {
    private final FinanceAuditService financeAuditService;

    /**
     * 审核镇级财务公开
     *
     * @param auditFinanceReq
     * @return
     */
    @RequestMapping("/audit/finance/auditFinanceByZJCW")
    public BaseResponse<Boolean> auditFinanceByZJCW(@Validated AuditFinanceReq auditFinanceReq) throws SzException {
        financeAuditService.auditFinanceByZJCW(auditFinanceReq);
        return BaseResponse.success(Boolean.TRUE);
    }

    /**
     * 审核的三资+报表是否通过
     *
     * @param auditFinanceReq
     * @return
     * @throws SzException
     */
    @RequestMapping("/finance-audit")
    public BaseResponse<?> financeAudit(@Validated AuditFinanceReq auditFinanceReq) throws SzException {
        financeAuditService.auditFinance(auditFinanceReq);
        return BaseResponse.success(Boolean.TRUE);
    }

    /**
     * 转为草稿
     *
     * @param id
     * @return
     */
    @RequestMapping("/finance-cg")
    public BaseResponse<?> changeChangeCaoGao(Integer id) throws SzException {
        financeAuditService.changeCaoGao(id);
        return BaseResponse.success(Boolean.TRUE);
    }

    /**
     * 查询需要审核的三资+报表列表
     *
     * @param findAuditFinanceDto
     * @return
     * @throws SzException
     */
    @RequestMapping("/find-finance-audit-table")
    public BaseResponse<?> findFinanceAuditTable(FindAuditFinanceDto findAuditFinanceDto) throws SzException {
        return BaseResponse.success(financeAuditService.findAuditFinance(findAuditFinanceDto));
    }


    /**
     * 查询报表的详情接口
     *
     * @param financeId
     * @return
     */
    @RequestMapping("/find-finance-detail")
    public BaseResponse<?> findFinanceDetail(@NotNull Integer financeId) throws SzException {
        return BaseResponse.success(financeAuditService.findAuditFinanceDetail(financeId));
    }

    /**
     * 是否公开镇级财务公开
     *
     * @param openNewsReq
     * @return
     * @throws SzException
     */
    @RequestMapping("/audit/finance/openFinanceByZJCW")
    public BaseResponse<Boolean> openFinanceByZJCW(@Validated OpenNewsReq openNewsReq) throws SzException {
        financeAuditService.openFinanceByZJCW(openNewsReq);
        return BaseResponse.success(Boolean.TRUE);
    }
}
